package com.topscomm.main;

import javax.annotation.Resource;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import com.topscomm.pub.util.SpringUtil;

@SpringBootApplication
@EnableTransactionManagement
// @EnableDiscoveryClient
@ComponentScan(basePackages = { "com.topscomm" })
@EnableAutoConfiguration
public class BspApp implements TransactionManagementConfigurer {
	@Resource(name = "transactionManager")
	private PlatformTransactionManager defaultTxManager;

	public static void main(String[] args) {
		ApplicationContext ctx = SpringApplication.run(BspApp.class, args);
		SpringUtil springUtil = (SpringUtil) SpringUtil.getBean("springUtil");
		springUtil.setApplicationContext(ctx);
	}

	@Override
	public PlatformTransactionManager annotationDrivenTransactionManager() {
		return defaultTxManager;
	}
}
